package me.jastz.oauth2;

import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by zhiwen on 2017/8/11.
 */
@ControllerAdvice
public class GlobalControllerExceptionHandler {

    @ExceptionHandler(InsufficientAuthenticationException.class)
    public String insufficientAuthenticationException(HttpServletRequest request, Model model) {
        String clientId = request.getParameter("client_id");
        model.addAttribute("clientId", clientId);
        return "/login";
    }
}
